<template>
	<view class="positon-index">

		<view  class="boxbox">
<!-- 			<movable-view :x="screenWidth" :y="screenHeight" direction="all" :out-of-bounds='false' :inertia='false' style="z-index: 20;">
				<image src="../../static/resume/fabu.png" :class="{'fbimgcss':platform != 'ios','fbimgcss1' : platform == 'ios'}" @click="addclick()"></image>
			</movable-view> -->
			<view style="padding-top: 10rpx;text-align: center;display: flex;align-items: ;" v-if="token">
				<view style="margin-left: 50rpx;">
					今日剩余刷新次数: <text style="color: red;">{{num}}</text>
				</view>
				<!-- <view style="margin-left: auto;margin-right: 50rpx;">
					 置顶次数:<text style="color: red;">{{top}}</text>
				</view> -->
			</view>
			<view class="listlicss" v-for="(item,index) in zwList" :key='index'>
				<view class="listhboxcss" @click="clickinfo(item)">
					<text class="listhcss">{{item.title}}</text>
					<image src="../../static/resume/position_0.png" v-if="item.state == 0" style="width: 90rpx;height: 28rpx;"></image>
					<image src="../../static/resume/position_2.png" v-if="item.state == 2"  @click="lookBnt(item.no_tis)" style="width: 110rpx;height: 60rpx;"></image>
					<image src="../../static/resume/position_1.png" v-if="item.state == 1 && item.is_closure == 0" style="width: 90rpx;height: 28rpx;"></image>
					<image src="../../static/resume/position_3.png" v-if="item.state ==1 && item.is_closure == 1" style="width: 90rpx;height: 28rpx;"></image>
					<!-- <text class="listtcss color1" v-if="item.state == 0">审核中</text> -->
<!-- 					<text class="listtcss color2" v-if="item.state == 2" @click="lookBnt(item.no_tis)">审核失败</text> -->
<!-- 					<text class="listtcss color1" v-if="item.state == 1 && item.is_closure == 0">需求中</text>
					<text class="listtcss color1" v-if="item.state ==1 && item.is_closure == 1">已关闭</text> -->
				</view>
				<text class="monycss"  @click="clickinfo(item)">{{item.stitle}}</text>
				<view class="typeboxcss"  @click="clickinfo(item)">
					<view class="typeboxcss marrscss">
						<image src="../../static/resume/pio_1.png" class="imgcss"></image>
						<text class="typetcss">{{item.areas.title}}</text>
					</view>
					<view class="typeboxcss marrscss">
						<image src="../../static/resume/pio_2.png" class="imgcss"></image>
						<text class="typetcss">{{item.age.title}}</text>
					</view>
				</view>
				<view class="btmcss"  @click="clickinfo(item)">
					<text class="namecss">{{item.company.name}}</text>
					<text class="timecss">{{item.date}}</text>
				</view>
				<view class="fengecss"></view>
				<view class="btnboxcs">
					<view class="btn bor3 marrcss"   @click="delMember(item.id)">
						删除
					</view>
<!-- 					<view class="btn bor3 marrcss"  @click="stick(item)" v-if="item.is_closure == 0 && item.state ==1">
					<uni-datetime-picker v-model="maskText" :start="start" type="date" :clear-icon="false"  @change="change"><view style="text-align:center;line-height: 28px;">
						置顶
					</view></uni-datetime-picker>
					
					</view> -->
					<view class="btn bor3 marrcss" v-if="item.state == 1 && item.is_closure == 0" @click="refresh(item.id)">
						刷新
					</view>
					<view class="btn bor3 marrcss" v-if="item.state == 1 || item.state == 2"  @click="edit(item.id)">
						编辑
					</view>
					<view class="btn bor3" @click="cutBnt(item.id,'关闭需求')" v-if="item.is_closure == 0 && item.state ==1">			
						关闭需求
					</view>
					<view class="btn bor3" @click="cutBnt(item.id,'开启需求')" v-if="item.is_closure == 1 && item.state ==1">
						开启需求
					</view>
				</view>
			</view>
			<image src="../../static/resume/fabu.png" :class="{'fbimgcss':platform != 'ios','fbimgcss1' : platform == 'ios'}" @click="addclick()"></image>
			<!-- <empty v-if="!this.token" :text='text'/> -->
			<empty v-if="total=='-1'" :Height='200' :text='text'/>
			<empty v-if="total=='0'" :Height='200' :text='text'/>
		</view>
	</view>
</template>
<script>
	import * as resume from '@/api/resume.js'
	import empty from '@/components/empty/index.vue'
	export default {
		props:{
			zwList:Array,
			total:Number,
			text:String
		},
		components:{
			empty
		},
		name:"position",
		data() {
			return {
				token:'',
				num:'',
				top: '',
				start:'', //时间选择器最小选择的值
				maskText: '', //时间选择器默认选择的值是明天的
				maskTextData: {},
				platform: '',
				screenWidth:'',
				screenHeight:''
			};
		},
		mounted() {
			this.getStart()
			this.getSystemInfo()
			this.token = uni.getStorageSync('token')
			if(uni.getStorageSync('token')) {
				this.getRefreshsum()
			}
		},
		methods:{
			//获取当前机器型号
		   getSystemInfo() {
			var that = this
			uni.getSystemInfo({
			 success: function(res) {
			  that.platform = res.platform
			  that.screenWidth = res.screenWidth-100
			  that.screenHeight = res.windowHeight-200
			 }
			});
		   },
			// 时间选择器的最小值是当前日期加1
			getStart() {
				var dateTime=new Date();
				dateTime=dateTime.setDate(dateTime.getDate()+1);
				dateTime=new Date(dateTime);
				this.start = this.$tools.dateFormatSm(dateTime)
				this.maskText = this.$tools.dateFormatSm(dateTime)
			},
			// 查询刷新次数
			getRefreshsum() {
				resume.queryTheRemainingTimes().then(res=>{
					this.num = res.data.refresh_num
					this.top = res.data.company_vip_top
				})
			},
 			// 刷新需求
			refresh(id) {
				uni.showModal({
					title: '提示',
					content: `确定刷新该需求吗`,
					success:  (res)=> {
						if (res.confirm) {
							resume.refreshMemberPosition({id:id}).then(res=>{
								this.getRefreshsum()
								this.$emit('getList','1')
								this.$tools.succend(`刷新成功！`)
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
				
			},
			// 删除需求
			delMember(id) {
				uni.showModal({
					title: '提示',
					content: '确定删除该需求吗',
					success:  (res)=> {
						if (res.confirm) {
							resume.delMemberPosition({id:id}).then(res=>{
								this.$emit('getList','1')
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
				
			},
			// 切换需求状态
			cutBnt(id,text) {
				uni.showModal({
					title: '提示',
					content: `确定${text}吗`,
					success:  (res)=> {
						if (res.confirm) {
							resume.toggleMemberPosition({id:id}).then(res=>{
								this.$emit('getList','1')
								this.$tools.succend(`${text}成功！`)
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
				
			},
			
			//跳转发布需求
			addclick(){
				if(uni.getStorageSync('token')) {
					this.$tools.navigate('/pages/resume/release/index')
				} else {
					this.$tools.toast('请登录')
					setTimeout(()=>{
						uni.reLaunch({
							url: '/pages/login/index'
						})
					},1000)
				}
			},
			// 再次编辑
			edit(id){
				this.$tools.navigate(`/pages/resume/release/index?id=${id}`)
			},
			// 查看详情
			clickinfo(item){
				if(item.state == 1){
					this.$tools.navigate(`/pages/home/jobDetails/index?position_id=${item.id}&oneself=1`)
				}
			},
			// 审核失败
			lookBnt(e) {
				uni.showModal({
					title: '失败原因',
					content: e,
					success: (res)=> {
						if (res.confirm) {
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			// 时间选择器确定时间
			change(e) {
				this.maskText = e
				this.maskTextData.date = e
				resume.companyVipTop(this.maskTextData).then(res=>{
					this.$tools.succend('预约置顶成功!')
					this.getRefreshsum()
				})
			},
			// 置顶按钮
			stick(item) {
				this.maskTextData.positionid = item.id
				
			}
		}
	}
</script>

<style scoped lang="scss">
.positon-index{
	position: relative;
	height: 100vh;
	width: 100%;
	// .fbimgcss{
	// 	position: fixed;
	// 	bottom: 57px;
	// 	right: 0;
	// 	width: 160rpx;
	// 	height: 175rpx;
	// }
	// .fbimgcss1{
	// 	position: fixed;
	// 	bottom: 87px;
	// 	right: 0;
	// 	width: 160rpx;
	// 	height: 175rpx;
	// }
	.boxbox {
		height: 100%;
		width: 100%;
		padding-bottom: 50px;
		.fbimgcss{
			position: fixed;
			bottom: 57px;
			right: 0;
			z-index: 10;
			width: 160rpx;
			height: 175rpx;
		}
		.fbimgcss1{
			position: fixed;
			bottom: 87px;
			right: 0;
			z-index: 10;
			width: 160rpx;
			height: 175rpx;
		}
	}
	.listlicss{
		margin-top: 10px;
		width: calc(100% - 80rpx);
		padding:20px 40rpx 0;
		background-color: #fff;
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		justify-content: flex-start;
		.listhboxcss{
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.listhcss{
				font-size: 32rpx;
				color: #333;
				letter-spacing: -0.64rpx;
				font-weight: 600;
				width: 100%;
				white-space:nowrap;
				overflow: hidden;
				text-overflow: ellipsis; 
			}
			.listtcss{
				font-size: 32rpx;
				letter-spacing: -0.64rpx;
			}
			.color1{
				color: #41B6B5;
			}
			.color2 {
				color: red;
			}
		}
		.monycss {
			font-size: 32rpx;
			color: #F24C19;
			letter-spacing: -0.64px;
			font-weight: 600;
			margin: 6px 0;
		}
		.typeboxcss{
			display: flex;
			align-items: center;
			justify-content: flex-start;
			.marrscss{
				margin-right: 45rpx;
			}
			.imgcss{
				width: 30rpx;
				height: 30rpx;
			}
			.typetcss{
				margin-left: 10rpx;
				font-size: 26rpx;
				color: #666;
				letter-spacing: -0.52px;
			}
			.btmtcss{
				font-size: 26rpx;
				color: #9A9A9A;
				letter-spacing: -0.52px;
			}
		}
		.btmcss {
			margin: 8px 0 12px;
			display: flex;
			align-items: center;
			justify-content: space-between;
			width: 100%;
		
			.namecss {
				font-size: 24rpx;
				color: #666666;
			}
		
			.timecss {
				font-size: 24rpx;
				color: #999999;
			}
		}
		.fengecss{
			width: 100%;
			height: 0px;
			border-bottom: 1px solid #EDEDED;
		}
		.btnboxcs{
			padding: 17px 0;
			width: 100%;
			display: flex;
			align-content: center;
			justify-content: flex-end;
			.btn{
				width: 152rpx;
				height: 28px;
				border-radius: 6px;
				opacity: 1;
				font-size: 28rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			.bor1{
				color: #ff7700;
				border: 1px solid #FF7700;
			}
			.bor2{
				color: #41B6B5;
				border: 1px solid #41B6B5;
			}
			.bor3{
				color: #666666;
				border: 1px solid #666666;
				position: relative;
				.picker {
					position: absolute;
					top: 0;
					left: 0;
					width: 100%;
					height: 100%;
				}
			}
			.marrcss{
				margin-right: 10rpx;
			}
		}
	}
}
</style>